﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ClimbTracker.BusinessLogic.Entities;
using ClimbTracker.BusinessLogic.Dao;

namespace ClimbTracker
{
    public partial class Form1 : Form
    {

        private Competitor competitor1, competitor2, competitor3;
        private Competition competition1;
        private ClimbAttempt climbAttempt1, climbAttempt2, climbAttempt3;
        private WallInstallation hold1, hold2, hold3;
        private Route route1, route2, route3;


        public Form1()
        {
            InitializeComponent();

            // testing methods
            initCompetitors();
            initHolds();
            initRoutes();
            initClimbAttempts();
            initCompetitions();

        }

        private void initCompetitors()
        {
            competitor1 = new Competitor();
            competitor1.Age = 26;
            competitor1.Category = "Heavy weight";
            competitor1.Name = "Roy Dagan";
            competitor1.Nationality = "Israeli";
            competitor1.PicturePath = "C:/roy.jpg";
            competitor1.Ranking = 1;

            competitor2 = new Competitor();
            competitor2.Age = 27;
            competitor2.Category = "Heavy weight";
            competitor2.Name = "Eran Arkin";
            competitor2.Nationality = "Israeli";
            competitor2.PicturePath = "C:/eran.jpg";
            competitor2.Ranking = 2;

            competitor3 = new Competitor();
            competitor3.CompetitorID = 0;
            competitor3.Age = 26;
            competitor3.Category = "Heavy weight";
            competitor3.Name = "Gur Dotan";
            competitor3.Nationality = "Israeli";
            competitor3.PicturePath = "C:/gur.jpg";
            competitor3.Ranking = 3;
        }

        private void initHolds()
        {
            hold1 = new WallInstallation();
            hold1.Color = "Red";
            hold1.Height = 10;
            hold1.Name = "hold1";
            hold1.Type = "HOLD";
            hold1.XCoordinate = 100;
            hold1.YCoordinate = 100;

            hold2 = new WallInstallation();
            hold2.Color = "Blue";
            hold2.Height = 20;
            hold2.Name = "hold2";
            hold2.Type = "HOLD";
            hold2.XCoordinate = 100;
            hold2.YCoordinate = 100;

            hold3 = new WallInstallation();
            hold3.Color = "Green";
            hold3.Height = 30;
            hold3.Name = "hold3";
            hold3.Type = "HOLD";
            hold3.XCoordinate = 100;
            hold3.YCoordinate = 100;
        }

        private void initRoutes()
        {
            route1 = new Route();
            route1.Difficulty = 5.5;
            route1.MaxScore = 100;
            route1.Name = "route1";
            route1.PicturePath = "c:/pic1.jpg";
            route1.TimePeriodMinutes = 5;
            route1.WallInstallations.Add(hold1);
            route1.WallInstallations.Add(hold2);
            route1.WallInstallations.Add(hold3);

            route2 = new Route();
            route2.Difficulty = 7.5;
            route2.MaxScore = 120;
            route2.Name = "route2";
            route2.PicturePath = "c:/pic2.jpg";
            route2.TimePeriodMinutes = 7;
            route2.WallInstallations.Add(hold1);
            route2.WallInstallations.Add(hold3);

            route3 = new Route();
            route3.Difficulty = 9.5;
            route3.MaxScore = 130;
            route3.Name = "route3";
            route3.PicturePath = "c:/pic3.jpg";
            route3.TimePeriodMinutes = 8;
            route3.WallInstallations.Add(hold3);

        }

        private void initClimbAttempts()
        {
            climbAttempt1 = new ClimbAttempt();
            climbAttempt1.AttemptLog = "Trying, reached, fell";
            climbAttempt1.Score = 100;


            climbAttempt2 = new ClimbAttempt();
            climbAttempt2.AttemptLog = "Falling already on the start";
            climbAttempt2.Score = 200;


            climbAttempt3 = new ClimbAttempt();
            climbAttempt3.AttemptLog = "Loser";
            climbAttempt3.Score = 300;

        }

        private void initCompetitions()
        {

            // Create competition
            competition1 = new Competition();
            competition1.Name = "Cool comp";
            competition1.Description = "One hell of a comp";

            // Add competitors
            competition1.Competitors.Add(competitor1);
            competition1.Competitors.Add(competitor2);
            competition1.Competitors.Add(competitor3);
            //competition1.DBcreate();

            // Remove one competitor
            competition1.Competitors.Remove(competitor1);
            //competition1.DBsave();

            competition1.ClimbAttempts.Add(climbAttempt1);
            competition1.ClimbAttempts.Add(climbAttempt2);
            competition1.ClimbAttempts.Add(climbAttempt3);
            //competition1.DBsave();

            competition1.ClimbAttempts.Remove(climbAttempt3);
            competitor1.ClimbAttempts.Add(climbAttempt3);

            //competition1.DBsave();


            competition1.Routes.Add(route1);
            competition1.Routes.Add(route2);
            competition1.Routes.Add(route3);

            competition1.DBcreate();


            route1.WallInstallations.Remove(hold2);
            route1.WallInstallations.Remove(hold3);


            competition1.DBsave();
            route1.DBsave();
            

                competition1.DBdelete();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

    }
}